package at.fhj.itm.weather;

import java.util.Observable;

import android.os.AsyncTask;

public class WeatherDataLoader extends Observable {

	public static WeatherDataLoader createYahooLoader() {
		final WeatherDataYahoo weatherLoader = new WeatherDataYahoo();
		final WeatherDataLoader weatherDataLoader = new WeatherDataLoader(
				weatherLoader);
		weatherLoader.setWeatherDataListener(weatherDataLoader);
		return weatherDataLoader;
	}

	public WeatherDataLoader(
			AsyncTask<String, Integer, WeatherData> weatherLoader) {
		this.weatherLoader = weatherLoader;
	}

	private AsyncTask<String, Integer, WeatherData> weatherLoader;

	public void update(WeatherData data) {
		this.setChanged();
		this.notifyObservers(data);
	}

	public void loadData(String location) {
		weatherLoader.execute(location);
	}

}
